package vis.items.visualItem;

import processing.core.PApplet;

public class RectObject extends VisualObject implements IVisualObject {

	private boolean isFilled;

	public RectObject(PApplet root, IVisualObject parent) {
		super(root, parent);
		this.isFilled = true;
	}

	public RectObject fill(boolean isFilled) {
		this.isFilled = isFilled;
		return this;
	}

	public String toString() {
		String s = super.toString();
		return s + "{fill=" + isFilled + "}";
	}

	@Override
	public void updateItself() {
		super.updateItself();
	}

	@Override
	public void displayItself() {
		if (isFilled) {
			_displayWithFill();
		} else {
			_displayNoFill();
		}
	}

	private void _displayWithFill() {
		root.fill(color.getRed(), color.getGreen(), color.getBlue());
		{
			root.noStroke();
			root.rect(x + offsetX, y + offsetY, width, height);
			// root.rect(x, y, width, height);
		}
		root.noFill();
	}

	private void _displayNoFill() {
		root.stroke(color.getRed(), color.getGreen(), color.getBlue());
		{
			root.rect(x + offsetX, y + offsetY, width, height);
			// root.rect(x, y, width, height);
		}
		root.noStroke();
	}
}
